//
//  M1SaveTool.m
//  NewMarryU
//
//  Created by apple on 2018/7/20.
//  Copyright © 2018年 Cedar. All rights reserved.
//

#import "M1SaveTool.h"

static NSString *const m1_appConfig_key = @"appconfig";
static NSString *const m1_user_key = @"userconfig";
static NSString *const m1_gender_key = @"gender";
static NSString *const m1_location_key = @"location";
@implementation M1SaveTool
+(void)m1_saveAppConfig:(NSDictionary *)config{
    [[NSUserDefaults standardUserDefaults] setObject:config forKey:m1_appConfig_key];
    [[NSUserDefaults standardUserDefaults] synchronize];
    
}

+(M1AppConfigModel *)m1_appConfig{
    NSDictionary *config = [[NSUserDefaults standardUserDefaults] objectForKey:m1_appConfig_key];
    M1AppConfigModel *configModel = [M1AppConfigModel mj_objectWithKeyValues:config];
    return  configModel;
}

+(void)m1_saveUserConfig:(NSDictionary *)config{
    [[NSUserDefaults standardUserDefaults] setObject:config forKey:m1_user_key];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+(M1User *)m1_userConfig{
    NSDictionary *config = [[NSUserDefaults standardUserDefaults] objectForKey:m1_user_key];
    if (!config) {
        return nil;
    }
    M1User *userModel = [M1User mj_objectWithKeyValues:config];
    return  userModel;
}

+(void)m1_removeUser{
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:m1_user_key];
}

+(void)m1_saveGender:(NSString *)gender{
    [[NSUserDefaults standardUserDefaults] setObject:gender forKey:m1_gender_key];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+(NSString *)m1_getGender{
    return  [[NSUserDefaults standardUserDefaults] objectForKey:m1_gender_key];
}

+(void)m1_saveLocation:(NSDictionary *)location{
    [[NSUserDefaults standardUserDefaults] setObject:location forKey:m1_location_key];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+(NSDictionary *)m1_Location{
    NSDictionary *config = [[NSUserDefaults standardUserDefaults] objectForKey:m1_location_key];
    if (!config) {
        return nil;
    }
    return config;
}
+(void )m1_removeLocation{
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:m1_location_key];
}
@end
